#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Create by zhang
# Create on 2022/6/21 17:18
from domain.common.base_dto import BaseDTO
from domain.common.base_schema import BaseSchema
from domain.common.schema_item import SchemaItem
from domain.report.common.period_enum import PeriodEnum


class BalanceSheetDTO(BaseDTO):
    def __init__(self):
        self.stock_id:int = None
        self.stock_code:str = None
        self.stock_name:str = None
        self.year:int = None
        self.period:PeriodEnum = None
        self.is_consolidate:bool = False

        self.money_cap = None
        self.sett_rsrv = None
        self.loanto_oth_bank_fi = None
        self.tradable_financial_assets = None
        self.bills_receivable = None
        self.account_receivable = None
        self.pre_payment = None
        self.premium_receiv = None
        self.reinsur_receiv = None
        self.reinsur_res_receiv = None
        self.interest_receivable = None
        self.dividend_receivable = None
        self.other_receivable = None
        self.pur_resale_fa = None
        self.inventories = None
        self.nca_within_1y = None
        self.other_current_assets = None
        self.total_current_assets = None
        self.decr_in_disbur = None
        self.saleable_financial_asset = None
        self.held_to_maturity_invest = None
        self.lt_receivable = None
        self.lt_equity_invest = None
        self.invest_property_estate = None
        self.fixed_asset = None
        self.fixed_asset_net = None
        self.construction_in_process = None
        self.project_goods_and_material = None
        self.fixed_assets_disposal = None
        self.productive_biological_asset = None
        self.oil_and_gas_assets = None
        self.intangible_assets = None
        self.dev_expenditure = None
        self.goodwill = None
        self.lt_to_expense = None
        self.total_dta = None
        self.other_noncurrent_assets = None
        self.total_noncurrent_assets = None
        self.total_assets = None
        self.st_loan = None
        self.cb_borr = None
        self.depos_ib_deposits = None
        self.loan_oth_bank = None
        self.tradable_financial_liab = None
        self.bill_payable = None
        self.accounts_payable = None
        self.pre_receivable = None
        self.sold_for_repur_fa = None
        self.comm_payable = None
        self.payroll_payable = None
        self.lt_payroll_payable = None
        self.taxes_payable = None
        self.interest_payable = None
        self.dividend_payable = None
        self.other_payable = None
        self.payable_to_reinsurer = None
        self.rsrv_insur_cont = None
        self.acting_trading_sec = None
        self.acting_uw_sec = None
        self.noncurrent_liab_due_in1y = None
        self.other_current_liab = None
        self.total_current_liab = None
        self.lt_loan = None
        self.bond_payable = None
        self.lt_payable = None
        self.specific_payables = None
        self.estimated_liab = None
        self.total_dtc = None
        self.other_noncurrent_liab = None
        self.total_noncurrent_liab = None
        self.total_liab = None
        self.shares = None
        self.capital_reserve = None
        self.treasury_share = None
        self.surplus_rese = None
        self.general_risk_provision = None
        self.undistr_porfit = None
        self.forex_differ = None
        self.total_parent_corp_equity = None
        self.minority_equity = None
        self.total_holders_equity = None
        self.total_liab_and_holders_equity = None

        self.contract_liabilities = None
        self.contractual_assets = None
        self.derivative_financial_liab = None
        self.noncurrent_liab_di = None
        self.other_illiquid_financial_assets = None
        self.other_comprehensive_income = None
        self.other_eq_ins_invest = None
        self.special_reserve = None
        self.to_sale_asset = None
        self.to_sale_debt = None
        self.deferred_income_tax_asset = None
        self.deferred_income_tax_liab = None
        self.other_obligation_invest = None
        self.use_right_asset = None
        self.account_receivable_factoring = None
        self.bank_appropriation_for_account_receivable_factoring = None
        self.bank_appropriation_for_lt_account_receivable_factoring = None


class BalanceSheetSchema(BaseSchema):
    _schemas = [
        SchemaItem(name="stock_id", title="股票代码(数字)", value_type=str, is_must=True),
        SchemaItem(name="stock_code", title="股票代码（字符串，带交易所简称）", value_type=str, is_must=True),
        SchemaItem(name="stock_name", title="股票名称", value_type=str, is_must=True),
        SchemaItem(name="year", title="年份", value_type=int, is_must=True),
        SchemaItem(name="period", title="报表周期类型", value_type=PeriodEnum, is_must=True),
        SchemaItem(name="is_consolidate", title="是否是合并报表", value_type=bool, is_must=True),
        # 资产
        #      流动资产
        SchemaItem(name="money_cap", title="货币资金", value_type=float, is_must=True),
        SchemaItem(name="sett_rsrv", title="结算备付金", value_type=float, is_must=True),
        SchemaItem(name="loanto_oth_bank_fi", title="拆出资金", value_type=float, is_must=True),
        SchemaItem(name="tradable_financial_assets", title="交易性金融资产", value_type=float, is_must=True),
        SchemaItem(name="derivative_financial_assets", title="衍生金融资产", value_type=float, is_must=True),
        SchemaItem(name="bills_receivable", title="应收票据", value_type=float, is_must=True),
        SchemaItem(name="account_receivable", title="应收账款", value_type=float, is_must=True),
        SchemaItem(name="fund_receivable_financial", title="应收款项融资 ", value_type=float, is_must=True),
        SchemaItem(name="account_receivable_factoring", title="应收账款保理", value_type=float, is_must=True),
        SchemaItem(name="pre_payment", title="预付款项", value_type=float, is_must=True),
        SchemaItem(name="premium_receiv", title="应收保费", value_type=float, is_must=True),
        SchemaItem(name="reinsur_receiv", title="应收分保账款", value_type=float, is_must=True),
        SchemaItem(name="reinsur_res_receiv", title="应收分保合同准备金", value_type=float, is_must=True),
        SchemaItem(name="other_receivable", title="其他应收款", value_type=float, is_must=True),
        SchemaItem(name="interest_receivable", title="应收利息", value_type=float, is_must=True),
        SchemaItem(name="dividend_receivable", title="应收股利", value_type=float, is_must=True),
        SchemaItem(name="pur_resale_fa", title="买入返售金融资产", value_type=float, is_must=True),
        SchemaItem(name="inventories", title="存货", value_type=float, is_must=True),
        SchemaItem(name="contractual_assets", title="合同资产", value_type=float, is_must=True),
        SchemaItem(name="to_sale_asset", title="持有待售资产", value_type=float, is_must=True),
        SchemaItem(name="to_sale_asset", title="持有待售的资产", value_type=float, is_must=True),
        SchemaItem(name="nca_within_1y", title="一年内到期的非流动资产", value_type=float, is_must=True),
        SchemaItem(name="other_current_assets", title="其他流动资产", value_type=float, is_must=True),
        SchemaItem(name="total_current_assets", title="流动资产合计", value_type=float, is_must=True),

        #      非流动资产
        SchemaItem(name="decr_in_disbur", title="发放贷款和垫款", value_type=float, is_must=True),
        SchemaItem(name="obligation_invest", title="债权投资", value_type=float, is_must=True),
        SchemaItem(name="other_obligation_invest", title="其他债权投资", value_type=float, is_must=True),
        SchemaItem(name="lt_receivable", title="长期应收款", value_type=float, is_must=True),
        SchemaItem(name="lt_account_receivable_factoring", title="长期应收款保理", value_type=float, is_must=True),
        SchemaItem(name="lt_equity_invest", title="长期股权投资", value_type=float, is_must=True),
        SchemaItem(name="other_eq_ins_invest", title="其他权益工具投资", value_type=float, is_must=True),
        SchemaItem(name="other_illiquid_financial_assets", title="其他非流动金融资产", value_type=float, is_must=True),
        SchemaItem(name="invest_property_estate", title="投资性房地产", value_type=float, is_must=True),
        SchemaItem(name="fixed_asset", title="固定资产", value_type=float, is_must=True),
        SchemaItem(name="construction_in_process", title="在建工程", value_type=float, is_must=True),
        SchemaItem(name="productive_biological_asset", title="生产性生物资产", value_type=float, is_must=True),
        SchemaItem(name="oil_and_gas_assets", title="油气资产", value_type=float, is_must=True),
        SchemaItem(name="use_right_asset", title="使用权资产", value_type=float, is_must=True),
        SchemaItem(name="intangible_assets", title="无形资产", value_type=float, is_must=True),
        SchemaItem(name="r_and_d", title="开发支出", value_type=float, is_must=True),
        SchemaItem(name="goodwill", title="商誉", value_type=float, is_must=True),
        SchemaItem(name="lt_to_expense", title="长期待摊费用", value_type=float, is_must=True),
        SchemaItem(name="deferred_income_tax_asset", title="递延所得税资产", value_type=float, is_must=True),
        SchemaItem(name="other_noncurrent_assets", title="其他非流动资产", value_type=float, is_must=True),
        SchemaItem(name="total_noncurrent_assets", title="非流动资产合计", value_type=float, is_must=True),

        SchemaItem(name="total_assets", title="资产总计", value_type=float, is_must=True),
        # 负债
        #      流动负债
        SchemaItem(name="st_loan", title="短期借款", value_type=float, is_must=True),
        SchemaItem(name="cb_borr", title="向中央银行借款", value_type=float, is_must=True),
        SchemaItem(name="loan_oth_bank", title="拆入资金", value_type=float, is_must=True),
        SchemaItem(name="tradable_financial_liab", title="交易性金融负债", value_type=float, is_must=True),
        SchemaItem(name="bank_appropriation_for_account_receivable_factoring", title="应收账款保理之银行拨款", value_type=float, is_must=True),
        SchemaItem(name="derivative_financial_liab", title="衍生金融负债", value_type=float, is_must=True),
        SchemaItem(name="bill_payable", title="应付票据", value_type=float, is_must=True),
        SchemaItem(name="accounts_payable", title="应付账款", value_type=float, is_must=True),
        SchemaItem(name="pre_receivable", title="预收款项", value_type=float, is_must=True),
        SchemaItem(name="contract_liabilities", title="合同负债", value_type=float, is_must=True),
        SchemaItem(name="sold_for_repur_fa", title="卖出回购金融资产款", value_type=float, is_must=True),
        SchemaItem(name="depos_ib_deposits", title="吸收存款及同业存放", value_type=float, is_must=True),
        SchemaItem(name="acting_trading_sec", title="代理买卖证券款", value_type=float, is_must=True),
        SchemaItem(name="acting_uw_sec", title="代理承销证券款", value_type=float, is_must=True),
        SchemaItem(name="payroll_payable", title="应付职工薪酬", value_type=float, is_must=True),
        SchemaItem(name="taxes_payable", title="应交税金", value_type=float, is_must=True),
        SchemaItem(name="taxes_payable", title="应交税费", value_type=float, is_must=True),
        SchemaItem(name="other_payable", title="其他应付款", value_type=float, is_must=True),
        SchemaItem(name="interest_payable", title="应付利息", value_type=float, is_must=True),
        SchemaItem(name="dividend_payable", title="应付股利", value_type=float, is_must=True),
        SchemaItem(name="comm_payable", title="应付手续费及佣金", value_type=float, is_must=True),
        SchemaItem(name="payable_to_reinsurer", title="应付分保账款", value_type=float, is_must=True),
        SchemaItem(name="to_sale_debt", title="划分为持有待售的负债", value_type=float, is_must=True),
        SchemaItem(name="to_sale_debt", title="持有待售的负债", value_type=float, is_must=True),
        SchemaItem(name="to_sale_debt", title="持有待售负债", value_type=float, is_must=True),
        SchemaItem(name="estimated_liab", title="预计负债", value_type=float, is_must=True),
        SchemaItem(name="noncurrent_liab_due_in1y", title="一年内到期的非流动负债", value_type=float, is_must=True),
        SchemaItem(name="other_current_liab", title="其他流动负债", value_type=float, is_must=True),
        SchemaItem(name="total_current_liab", title="流动负债合计", value_type=float, is_must=True),

        #      非流动负债
        SchemaItem(name="rsrv_insur_cont", title="保险合同准备金", value_type=float, is_must=True),
        SchemaItem(name="lt_loan", title="长期借款", value_type=float, is_must=True),
        SchemaItem(name="bond_payable", title="应付债券", value_type=float, is_must=True),
        # SchemaItem(name="bond_payable_preferred_stock", title="优先股", value_type=float, is_must=True),
        # SchemaItem(name="bond_payable_sustainable_debt", title="永续债", value_type=float, is_must=True),
        SchemaItem(name="bank_appropriation_for_lt_account_receivable_factoring", title="长期应收款保理之银行拨款", value_type=float, is_must=True),
        SchemaItem(name="hire_debt", title="租赁负债", value_type=float, is_must=True),
        SchemaItem(name="lt_payable", title="长期应付款", value_type=float, is_must=True),
        SchemaItem(name="lt_payroll_payable", title="长期应付职工薪酬", value_type=float, is_must=True),
        SchemaItem(name="noncurrent_liab_di", title="递延收益-非流动负债", value_type=float, is_must=True),
        SchemaItem(name="noncurrent_liab_di", title="递延收益", value_type=float, is_must=True),
        SchemaItem(name="deferred_income_tax_liab", title="递延所得税负债", value_type=float, is_must=True),
        SchemaItem(name="other_noncurrent_liab", title="其他非流动负债", value_type=float, is_must=True),
        SchemaItem(name="total_noncurrent_liab", title="非流动负债合计", value_type=float, is_must=True),

        SchemaItem(name="total_liab", title="负债合计", value_type=float, is_must=True),
        # 股东权益
        SchemaItem(name="shares", title="实收资本(或股本)", value_type=float, is_must=True),
        SchemaItem(name="shares", title="实收资本", value_type=float, is_must=True),
        SchemaItem(name="shares", title="股本", value_type=float, is_must=True),
        SchemaItem(name="capital_reserve", title="资本公积", value_type=float, is_must=True),
        SchemaItem(name="treasury_share", title="库存股", value_type=float, is_must=True),
        SchemaItem(name="other_comprehensive_income", title="其他综合收益", value_type=float, is_must=True),
        SchemaItem(name="special_reserve", title="专项储备", value_type=float, is_must=True),
        SchemaItem(name="surplus_rese", title="盈余公积", value_type=float, is_must=True),
        SchemaItem(name="general_risk_provision", title="一般风险准备", value_type=float, is_must=True),
        SchemaItem(name="undistr_porfit", title="未分配利润", value_type=float, is_must=True),
        SchemaItem(name="total_parent_corp_equity", title="归属于母公司所有者权益（或股东权益）合计 ", value_type=float, is_must=True),
        SchemaItem(name="total_parent_corp_equity", title="归属于母公司所有者权益合计 ", value_type=float, is_must=True),
        SchemaItem(name="total_parent_corp_equity", title="归属于母公司普通股股东权益合计 ", value_type=float, is_must=True),
        SchemaItem(name="total_parent_corp_equity", title="归属于母公司股东权益合计 ", value_type=float, is_must=True),
        SchemaItem(name="minority_equity", title="少数股东权益", value_type=float, is_must=True),

        SchemaItem(name="total_holders_equity", title="所有者权益（股东权益）合计", value_type=float, is_must=True),
        SchemaItem(name="total_holders_equity", title="所有者权益合计", value_type=float, is_must=True),
        SchemaItem(name="total_holders_equity", title="股东权益合计", value_type=float, is_must=True),

        SchemaItem(name="total_liab_and_holders_equity", title="负债和所有者权益（或股东权益）合计", value_type=float, is_must=True),
        SchemaItem(name="total_liab_and_holders_equity", title="负债和所有者权益合计", value_type=float, is_must=True),
        SchemaItem(name="total_liab_and_holders_equity", title="负债和股东权益合计", value_type=float, is_must=True),
        SchemaItem(name="total_liab_and_holders_equity", title="负债和股东权益总计", value_type=float, is_must=True),

        # 未分类
        SchemaItem(name="pre_payment", title="预付账款", value_type=float, is_must=True),
        SchemaItem(name="saleable_financial_asset", title="可供出售金融资产", value_type=float, is_must=True),
        SchemaItem(name="held_to_maturity_invest", title="持有至到期投资", value_type=float, is_must=True),
        SchemaItem(name="fixed_asset_net", title="固定资产净额", value_type=float, is_must=True),
        SchemaItem(name="project_goods_and_material", title="工程物资", value_type=float, is_must=True),
        SchemaItem(name="fixed_assets_disposal", title="固定资产清理", value_type=float, is_must=True),
        SchemaItem(name="total_dta", title="递延税款借项合计", value_type=float, is_must=True),
        SchemaItem(name="specific_payables", title="专项应付款", value_type=float, is_must=True),
        SchemaItem(name="total_dtc", title="递延税款贷项合计", value_type=float, is_must=True),
        SchemaItem(name="forex_differ", title="外币报表折算差额", value_type=float, is_must=True),
        SchemaItem(name="to_sale_asset", title="划分为持有待售的资产", value_type=float, is_must=True)
    ]

    _name2schema = {}

    _title2name = {}
